<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use App\Models\CrawlerArticle;
class SendArticle extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'tx:send-article {num=1}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '发布文档任务';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle(CrawlerArticle $arc)
    {
        $num = $this->argument('num');
        $this->info('准备发布文档');
        if ($arc->sendArticle($num)) $this->info('发布了' . $num . '篇文档');
        else $this->info('没有需要发布的文档！');
    }
}
